<!DOCTYPE html>
<html lang="id">
<head>
	<title><?php echo PROJECT_NAME; ?></title>
	<meta charset="utf-8">
	<meta content='id' http-equiv='Content-Language'/>
	<meta content='<?php echo PROJECT_NAME; ?>' name='description'/>
	<meta content='INDEX,NOFOLLOW' name='robots'/>
	<meta content='Sistem Monitoring Anggaran' name='keywords'/>
	<meta content='1 days' name='revisit-after'/>
	<meta content='1 days' name='revisit'/>
	<link href='#' rel='shortcut icon'/>
	
	<?php
		// ASSETS //;
		echo css_asset('style.css');
		
		/* theme */
		echo css_asset('default.css','theme/thegreenhouse');
	?>
	<!-- assets -->
	<?php  echo js_asset("jquery-1.9.1.js","jquery-ui-1.10.3.custom"); ?>
	<?php echo js_asset("jquery-ui-1.10.3.custom.min.js","jquery-ui-1.10.3.custom"); ?>
	
	<?php echo js_asset("jquery.jqGrid.min.js","jquery.jqGrid-4.5.2"); ?>
	<?php echo js_asset("i18n/grid.locale-id.js","jquery.jqGrid-4.5.2"); ?>
	<?php echo js_asset('jquery.fmatter.js','jquery.jqGrid-4.5.2'); ?>
	
	<?php echo js_asset("jquery-ui.combobox.js",""); ?>
	<?php echo js_asset('jquery.formatCurrency-1.4.0.js',''); ?>
	
	<?php echo js_asset('chosen.jquery.js','chosen'); ?>
	<?php echo css_asset("chosen.css","chosen"); ?>
	
	<?php echo css_asset("blitzer/jquery-ui.css","jquery-ui-1.10.3.custom"); ?>
	<?php echo css_asset("blitzer/jquery.ui.theme.css","jquery-ui-1.10.3.custom"); ?>
	<?php echo css_asset("ui.jqgrid.css","jquery.jqGrid-4.5.2"); ?>
	
	
</head>

<script>
	$(function(){
		/* external function */
	
		$.fn.justCombobox = function(data, key, label){
			var field = $(this);
			$.ajax({
				url : "c_public_function",
				data : data,
				type : 'POST', dataType : 'json'
			}).done(function(response){
				for(i=0;i<response.length;i++){
					field.append("<option value="+response[i][key]+">"+response[i][label]+"</option>");
				}
				<?php if (@$_SESSION[SESSION_DIV] == "") { ?>
					field.change();
				<?php }else{ ?>
					field.val(<?php echo @$_SESSION[SESSION_DIV]; ?>);
					field.change();
				<?php } ?>
			});
		}
		
		function urlparamToObject(urlparam){
            if (urlparam != ""){
			return JSON.parse('{"' + decodeURI(urlparam).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
            }
		}
		
		/* declarisasi */
		menus = $(".menus");
		main_content = $("#main-content");
		lbl_title = $(".title");
		div_change = $("#div_change");
		current_url = "c_index";
		current_param = "task=home";
		current_title = "";
		
		/* function */
		
		function gohome(){
			param = urlparamToObject("task=home");
			main_content.load("c_index",param);
			lbl_title.text("Welcome to Sistem Pendaftaran Proyek Baru - PT. PP");
		}
		
		function refresh(){
			param = urlparamToObject(current_param);
			main_content.load(current_url,param);
			lbl_title.text(current_title);
		}
		
		/* make component */
		div_change.justCombobox({ task : "divbyuser"},"div_id","div_name");
		
		/* event */
		menus.click(function(){
			data = $(this).data();
			
			if (data.url != ""){
				current_url = data.url;
				current_param = data.param;
				current_title = $(this).text();
				var param = null;
				var urlparam = data.param ;
				if (urlparam != null && urlparam != "" )
					param = urlparamToObject(urlparam);
				
				main_content.load(data.url,param);
				lbl_title.text($(this).text());
			}
		});
        
        menus.first().click();
        
		//$(".menus:contains('Project')").click();
        
		div_change.change(function(){
			$.ajax({
				url : "c_public_function",
				data : {task : "setdiv", div_id : div_change.val()},
				type : 'POST', dataType : 'json'
			}).done(function(response){
				refresh();
			});
		});
	   $("#close").click(function(){
            $(".alert").hide("show");
       });
    
    });
	
</script>
    <style>
        .alert{
            border : 1px solid #e00;
            border-radius : 5px;
            padding : 20px;
            margin-bottom : 20px;
            background : #eaa;
            font-weight : bold;
            color : #000;
        }
        </style>
<body>
<div id="menu">
  <ul>
    <li class="active"><a><?php echo strtoupper(PROJECT_NAME); ?></a></li>
  </ul>
  <div style="float:right;margin:10px 20px">
  <?php if($_SESSION[SESSION_GROUPTIPE] == 1  ){ ?>
  <span style="color:#eee">Sign In As</span> : <select id="div_change"></select> |  <b style="color:#000;">
      
      <?php 
       if ( $_SESSION[SESSION_NAMADIV] != "" ) 
          echo "(".$_SESSION[SESSION_NAMADIV].")"; ?>
      
      </b>
  <?php }?>
  
  <a href="c_login/logout" style="padding:0;margin:0;display:inline;margin-left:20px;"> Logout</a>
  </div>
</div>
<div id="wrapper">
<p>&nbsp;</p>
  <div id="content">
    <div id="posts">
      <div class="post">
         <?php if (count($alert) > 0){?> 
       <div class="alert">Segera proses :<br />
          <?php for($i=0;$i<count($alert);$i++){
                echo "- ".$alert[$i]->doc." Proyek ".$alert[$i]->project_name." ( ".$alert[$i]->project_code." )<br />";
            } ?>
          <p>&nbsp;</p>
          <a href="#" id="close" >close</a></div>
          <?php } ?>
        <h2 class="title">Welcome to <?php echo PROJECT_NAME; ?></h2>
		<div >
        <div class="story" >
          <p id="main-content" style="margin-top:50px">
		  
		  
		  </p>
        </div>
		</div>
      </div>
    </div>
    <div id="links">
	
		<?php  foreach($menus as $key=>$menu){ ?>
          <ul>
			<li>
			  <h2><?php echo ucwords(strtolower($key)); ?></h2>
			  <ul>
				<?php foreach($menu as $child_menu){ ?>
					<li><a data-url="<?php echo $child_menu->menus_url; ?>" data-param="<?php echo $child_menu->menus_param; ?>" class="menus"  ><span><?php echo ucwords(strtolower($child_menu->menus_label)); ?></span></a></li>
				<?php } ?>
			  </ul>
			</li>
		  </ul>
		<?php } ?>
    </div>
    <div style="clear: both;">&nbsp;</div>
  </div>
</div>
<div id="footer">
  <p id="legal">Copyright &copy; 2013</p>
  <p id="brand"><?php echo PROJECT_NAME; ?></p>
</div>
</body>
</html>
